import {config, request} from 'utils'

const {api} = config
const {orders} = api

export const status = {
  2: {text: '待审核', badge: 'processing'},
  3: {text: '审核不通过', badge: 'error'},
  4: {text: '审核通过待发货', badge: 'processing'},
  5: {text: '已发货', badge: 'processing'},
  6: {text: '已签收', badge: 'success'},
  7: {text: '退回中', badge: 'warning'},
  8: {text: '退回签收', badge: 'warning'},
  9: {text: '已取消', badge: 'error'},
}

export function toText (p) {
  const t = status[p]
  return t ? t['text'] : '错误状态'
}

export function toBadge (p) {
  const t = status[p]
  return t ? t['badge'] : 'error'
}

export function queryById (params) {
  return request({
    url: orders + '/detail',
    method: 'get',
    data: params,
  })
}

export function audit (params) {
  return request({
    url: orders + '/audit',
    method: 'put',
    data: params,
  })
}

export function traces (params) {
  return request({
    url: orders + '/traces',
    method: 'post',
    data: params,
  })
}
